mini.parse();
var grid = mini.get("widgetAttrGrid");
grid.load();
var projectName = $("#projectName").val();

function editWidgetAttr(row) {
	if(row){
		openWindowsWidgetAttr(row.id,"edit","编辑");
	 }else{
		 row = grid.getSelected();
		if(row){
			openWindowsWidgetAttr(row.id,"edit","编辑");
		}else{
			  mini.alert("请选中一条记录");
		}
	} 	
}
function openWindowsWidgetAttr(id,openType,WindowName){
	mini.open({
        url: projectName+"/WidgetAttrAdmin/EditPage",
        title: WindowName, width: 700, height: 500,
        onload: function () {
            var iframe = this.getIFrameEl();
            var data = { action: openType, id: id };
            iframe.contentWindow.CheckEventWidgetAttr(data);
        },
        ondestroy: function (action) {
            grid.reload();
        }
    });
}
function addWidgetAttr(){
	openWindowsWidgetAttr("","new","新增");
}
function removeWidgetAttr(){
	
}
function onrowdblclick(e){
	 var record = e.record;
	openWindowsWidgetAttr(record.id,"look","查看");
}


function seachRow(){
	 var form = new mini.Form("#formseach");
    var data = form.getData(true, false);
    grid.load(data);
	
}
function resetForm(){
	 var form = new mini.Form("#formseach");
     form.reset();
}
function exportWidgetAttr() {
	var rows = grid.getSelecteds();
	var idString = '';
	var url = projectName +"/WidgetAttrAdmin/exportWidgetAttrExcel?";
    if (rows.length > 0) {
	    var ids = [];
	    for (var i = 0, l = rows.length; i < l; i++) {
	        var r = rows[i];
	        ids.push(r.id);
	    }
	    idString = ids.join(',');    
	    mini.get("ids").setValue(idString);
	    util.exportDataToClient($('#WidgetAttrListForm'), url);
	} else {
		
		mini.confirm('导出全部？如查询条件不为空，则导出符合查询条件的所有数据.','确定？',function(action) {
			if (action == 'ok') {
				mini.get('ids').setValue('');
				util.exportDataToClient($('#WidgetAttrListForm'), url);
			} else {
				window.close();
			}
		});
	}
	
}
